<?php
require_once 'SurveysCompleted.php';

class Survey_SurveyCompletedController extends HTech_Controller_Action
{
    function init()
    {
        $cfg = array(
            'model' => 'SurveysCompleted',
            'config' => array('add' => 'surveys_completed', 'export' => 'surveys_completed'),
            'actionContext' => array(
                'export' => array('xml','csv'))
        );
        parent::init($cfg);  
    }
    
    public function exportAction()
    {
        ini_set('memory_limit','512M');
        $surveysCompleted = new SurveysCompleted(array('name' => 'surveys_completed'));
        $query = $surveysCompleted->select()
                ->where('SurveyId = ?', $this->_request->getParam('SurveyId'))
                ->where('QuestionId = ?', $this->_request->getParam('QuestionId'));
        $this->view->data = $surveysCompleted->fetchAll($query)->toArray();   
        $this->view->meta = $surveysCompleted->getGridMetadata();      
        $this->view->title = $this->view->translate('Survey data collected'); 
    }
}
